/**
 * 组件实例
 */
export const mkPatientFormRef = ref();

// #region data数据
import { TraFuHeInput, TraFuHeApi, TraFuHeOutput} from '/@/api/tra/TraFuHe';
import { ElMessage } from 'element-plus';

const initialState = () => ({
    isEdit: true,
    loading: false,
    master: {danJuLeiXing: '血型复核'} as TraFuHeInput,
});

// 使用 reactive 初始化
export const ctx = reactive(initialState());

export const newEntity = () => {
    Object.assign(ctx, initialState());
    mkPatientFormRef.value?.newEntity()
};

export const saveBill = () => {
    ctx.master.id = mkPatientFormRef.value?.ctx.traShenQingInput.id;
    TraFuHeApi.add(ctx.master ).then((res) => {
        ElMessage.success('保存成功');
        ctx.master = { ...ctx.master, ...res.result };
        ctx.isEdit = false;
    });
};


export const itemChange = (row: any) => {
    newEntity();
    ctx.isEdit = false;
    TraFuHeApi.get(row.id).then((res) => {
        console.log('TraShenQingApiTraShenQingApi', res);

        ctx.master = res as TraFuHeInput;
    });
};